﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data ;
using System.Windows.Forms;
using libDAL;

namespace libInventory.BUS
{
    sealed class clsBUSShipperConsignee  : IDisposable 
    {
       private DataTable dtShipperDetails;
       private DataTable dtConsigneeDetails;
       private cls_DAL _DAL;
       private DataRow[] drShipperDetails;
       private DataRow[] drConsigneeDetails;

       private struct strctQueries
       {
           public string get_CompanyDetails(string strCompanyID)
           {
               return "SELECT comid, comname, comname2, addbookcode, induscode, website, addline1, addline2, addline3, addline4, areacode, citycode, stacode, poscode, coucode, discode, " +
                      "email, connotepre, insper, insperfra, insminamt, minchaamt, contact, telpre, telno, faxpre, faxno, conope, slclotime, selected, regcust, glno, inscover, remarks, " +
                      "slotbook, bolprefix, holdgrn, holdrea, anote, nbl, fclinscover, fclinsper, fclinsperfra, fclinsminamt, fclstampduty, fclgovtax, memo, fcltermday, customcode, salperson, " +
                      "faxattn, markup, mpercent, byshipmea, allowvariance, cashbill, svbyemail, svbyfax, acccode, accid, billage, billbr, createdby, createddate, lastmodifiedby, " +
                      "lastmodifieddate, vip, minfrtrate, userreportprint, reportprintdate, reportprintby, hakgerakandate, svconsignee, autovesselsc, emailvesselsc, custgradecode, " +
                      "IsExportShprDO, mobilepre, mobileno, comtype, branchID, DateTimeInserted, DateTimeUpdated, HostNameIPAddress, OnUse, OnUseBy, comidHQ, " +
                      "companyHistoryID, comDefault, comStatus, oldcomid, portid, comregno " +
                      "FROM mfcompany " +
                      "WHERE ltrim(rtrim(comid)) = '" + strCompanyID + "'";
           }
       }

       private strctQueries getQueries;

       public clsBUSShipperConsignee(cls_DAL _DALL)
       {
           this._DAL = _DALL;
           getQueries = new strctQueries();
       }

       public DataRow[] get_ConsigneeDetails
       {
           get
           {
               return drConsigneeDetails;
           }
       }

       public DataRow[] get_ShipperDetails
       {
           get
           {
               return drShipperDetails;
           }
       }

       public bool set_ConsigneeDetails(string strCompanyID)
       {
           bool bolStatus = false;
           try
           {
              dtConsigneeDetails = new DataTable();
              dtConsigneeDetails = _DAL.get_TableDetail(getQueries.get_CompanyDetails(strCompanyID));
              drConsigneeDetails = dtConsigneeDetails.Select();
              bolStatus = true;
           }
           catch (Exception ex)
           {
               MessageBox.Show(ex.Message + " set_ShipperDetails");
           }
           return bolStatus;
       }

       public bool set_ShipperDetails(string strCompanyID)
       {
           bool bolStatus = false;
           try
           {
               dtShipperDetails = new DataTable();
               dtShipperDetails = _DAL.get_TableDetail(getQueries.get_CompanyDetails(strCompanyID));
               drShipperDetails = dtShipperDetails.Select();
               bolStatus = true;
           }
           catch (Exception ex)
           {
               MessageBox.Show(ex.Message + " set_ShipperDetails");
           }
           return bolStatus;
       }

       public void Dispose()
       {
           GC.Collect();
          // throw new NotImplementedException();
       }
    }
}
